﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Reloaders
{
    public abstract class ReloaderDecorator<T> : Reloader<T>
    {
        protected ReloaderDecorator(IReloaderPrototype<T> compositionBasePrototype, 
            Func<T> getValue, Action<T> applyValue, Action<bool> applyStatus)
        {
            if (compositionBasePrototype == null) throw new ArgumentNullException("compositionBasePrototype");

            _CompositionBase = compositionBasePrototype.Create(getValue, applyValue, applyStatus);

            if (_CompositionBase == null) throw new NotSupportedException(StringsCore.CANT_OBTAIN_RELOADER);
        }

        //=//

        protected readonly IReloader _CompositionBase;

        public override void Dispose()
        {
            _CompositionBase.Dispose();
        }
    }
}
